package com.sgb.kjwl.viewmodel.self.publish;

import androidx.databinding.ObservableField;

import com.sgb.kjwl.api.APIManager;
import com.sgb.kjwl.model.entity.CarBrandEntity;
import com.swgk.core.util.PickSelectEntity;
import com.sgb.kjwl.model.entity.user.AddCarEntity3;
import com.sgb.kjwl.model.entity.user.CommonPickerEntity3;
import com.sgb.kjwl.repository.SelfRepertory;
import com.sgb.kjwl.view.ui.activity.house.CarBrandActivity;
import com.sgb.kjwl.view.ui.activity.self.publish.CarPublishActivity1;
import com.swgk.core.base.BaseViewModel;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.dialog.DialogHelper;
import com.swgk.core.util.MToast;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import okhttp3.MediaType;
import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class CarBrandModel extends BaseViewModel {
    public ObservableField<AddCarEntity3> addCarEntity = new ObservableField<>(new AddCarEntity3());
    private CarBrandActivity activity;

    public CarBrandModel(CarBrandActivity activity) {
        this.activity = activity;
    }

    /**
     * 获取车辆品牌列表
     */
    public void getPickerCarBrand() {
        APIManager.getInstance().getUserAPI().getDictCarBrand().enqueue(new Callback<BaseEntity<List<CarBrandEntity>>>() {
            @Override
            public void onResponse(Call<BaseEntity<List<CarBrandEntity>>> call, Response<BaseEntity<List<CarBrandEntity>>> response) {
                if (response.body() == null || response.body().getState() == null) return;
                if (response.body() != null && response.body().getState().equals("ok")) {
                    activity.showBrandList(response.body().getData());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<CarBrandEntity>>> call, Throwable t) {

            }
        });
    }


}
